package com.goodving.guli.bt.model;

import com.goodving.guli.bt.Utils;
import com.goodving.guli.bt.profile.scale.GuliLog;
import com.goodving.guli.bt.profile.scale.HeartRateInfo;
import com.goodving.guli.model.UserTotalSportData;
import com.goodving.guli.view.MiliConfig;

import java.util.ArrayList;
import java.util.Calendar;

/**
 * Created by john on 2015/11/28.
 */
public class PersonInfo {
    public static final int COMPATIABLE_VALUE = 1000;
    public static final int INCOMING_CALL_DEFAULT = 258;
    public static final int INCOMING_CALL_DEFAULT_SEC = 2;
    public static final int INCOMING_CALL_DISABLE_BIT = 256;
    public static final int SYNC_AVATAR_NEEDED = 1;
    public static final int SYNC_OK = 0;
    public static final int SYNC_PERSON_NEEDED = 2;
    private static final String TAG = "PersonInfo";
    @Deprecated
    public int age;
    public ArrayList<AlarmClockItem> alarmClockItems;
    public String avatarPath;
    public String avatarUrl;
    public String birthday;
    public String createTime;
    public String deviceId;
    public int gender;
    public int gid;
    public int height;
    public String lastLoginTime;
//    public UserLocationData location;
    public MiliConfig miliConfig;
    private boolean miliSleepAssist;
    private int needSyncServer;
    public String nickname;
    public String personSignature;
    public String pinyin;
    public String sh;
    public String source;
    public int state;
    public float targetWeight;
    public UserTotalSportData totalSportData;
    public long uid;
    private int version;
    public float weight;

    /* renamed from: cn.com.smartdevices.bracelet.model.PersonInfo.1 */
//    final class C14491 extends TypeToken<ArrayList<AlarmClockItem>> {
//        C14491() {
//        }
//    }

    public PersonInfo() {
        // TBD hack here
        this.nickname = "";
        this.avatarUrl = "";
        this.avatarPath = "";
        this.gender = -1;
        this.height = -1;
        this.weight = -1;
        this.targetWeight = -1;
        this.birthday = ""; // default age
        this.age = -1;
        this.createTime = "";
        this.lastLoginTime = "";
        // TBD hack here
        this.uid = -1;
        this.source = "";
        this.state = SYNC_OK;
        this.gid = -1;
        this.personSignature = "";
        this.pinyin = "#";
        this.sh = "";
        this.deviceId = "";
        this.version = SYNC_OK;
//        this.totalSportData = new UserTotalSportData();
//        this.location = new UserLocationData();
        this.alarmClockItems = new ArrayList();
        this.miliConfig = new MiliConfig();
        this.needSyncServer = SYNC_OK;
    }

//    public static ArrayList<AlarmClockItem> parseAlarmClockItems(String str) {
//        try {
//            return (ArrayList) Utils.m8049c().fromJson(str, new C14491().getType());
//        } catch (Exception e) {
//            e.printStackTrace();
//            return null;
//        }
//    }

    public void clearNeedSyncServer() {
        this.needSyncServer = SYNC_OK;
    }

    public void disableInComingCallTime() {
        this.miliConfig.inComingCallNotifyTime = getInComingCallTime() | INCOMING_CALL_DISABLE_BIT;
        GuliLog.tracePrintInfo(TAG, "disable incoming = " + this.miliConfig.inComingCallNotifyTime);
    }

    public void enableAlarmNotify(boolean z) {
        this.miliConfig.alarmNotifyEnabled = z;
    }

    public void enableConnectedBtAdv(boolean z) {
        this.miliConfig.enableConnectedBtAdv = z;
    }

    public void enableInComingCallTime() {
        this.miliConfig.inComingCallNotifyTime = getInComingCallTime() & HeartRateInfo.HR_EMPTY_VALUE;
        GuliLog.tracePrintInfo(TAG, "enable incoming = " + this.miliConfig.inComingCallNotifyTime);
    }

    public void enableSmsNotify(boolean z) {
        this.miliConfig.smsNotifyEnabled = z;
    }

    public int getAge() {
        return this.age;
    }

//    public ArrayList<AlarmClockItem> getAlarmClockItems() {
//        if (this.alarmClockItems == null) {
//            this.alarmClockItems = new ArrayList();
//        }
//        if (this.alarmClockItems.size() < 3) {
//            ArrayList readMorningAlarms = Keeper.readMorningAlarms();
//            int i = SYNC_OK;
//            int size = this.alarmClockItems.size();
//            while (size < 3) {
//                int i2;
////                AlarmClockItem alarmClockItem = new AlarmClockItem();
//                if (readMorningAlarms == null || readMorningAlarms.size() <= i) {
//                    i2 = i;
//                } else {
////                    alarmClockItem.setCalendar((Calendar) readMorningAlarms.get(i));
//                    i2 = i + SYNC_AVATAR_NEEDED;
//                }
////                this.alarmClockItems.add(alarmClockItem);
//                size += SYNC_AVATAR_NEEDED;
//                i = i2;
//            }
//            Keeper.keepPersonInfo(this);
//            GuliLog.tracePrintInfo(TAG, "add new alarm size=" + this.alarmClockItems.size());
//        }
//        return this.alarmClockItems;
//    }

    public String getBirthday() {
        return this.birthday;
    }

    public int getDaySportGoalSteps() {
        return this.miliConfig.goalStepsCount;
    }

    public Calendar getFirstUseDate() {
        return this.miliConfig.firstUseDate;
    }

    public int getInComingCallTime() {
        return this.miliConfig.inComingCallNotifyTime & HeartRateInfo.HR_EMPTY_VALUE;
    }

//    public C3941i getMiLiHwConfig() {
//        int i = C3829q.f19340c;
//        C3941i c3941i = new C3941i();
//        if (getDaySportGoalSteps() > 0) {
//            c3941i.f19887b = getDaySportGoalSteps();
//        } else {
//            GuliLog.tracePrintInfo(TAG, "day sport goals is inValid!");
//        }
//        c3941i.f19888c = getAlarmClockItems();
//        if (this.miliConfig == null || this.miliConfig.lightColor == null) {
//            GuliLog.m12360b(TAG, "miliConfig is null or lightColor is null");
//        } else {
//            String str = this.miliConfig.lightColor;
//            if (!str.equals(MiliConfig.BLUE)) {
//                if (str.equals(MiliConfig.GREEN)) {
//                    i = C3829q.f19342e;
//                } else if (str.equals(MiliConfig.RED)) {
//                    i = C3829q.f19343f;
//                } else if (str.equals(MiliConfig.ORANGE)) {
//                    i = C3829q.f19341d;
//                }
//            }
//            c3941i.f19889d = i;
//        }
//        if (this.miliConfig == null || this.miliConfig.wearHand == null) {
//            GuliLog.m12360b(TAG, "miliConfig is null or wearHand is null");
//        } else {
//            String str2 = this.miliConfig.wearHand;
//            byte b = str2.equals(MiliConfig.LEFT_HAND) ? (byte) 0 : str2.equals(MiliConfig.RIGHT_HAND) ? (byte) 1 : str2.equals(MiliConfig.ONBODY) ? (byte) 2 : (byte) 0;
//            c3941i.f19891f = b;
//        }
//        if (this.miliConfig != null) {
//            c3941i.f19893h = this.miliConfig.sleepAssist;
//        }
//        if (this.miliConfig != null) {
//            c3941i.f19892g = this.miliConfig.enableConnectedBtAdv;
//        }
//        return c3941i;
//    }

    public String getMiliColor() {
        return this.miliConfig.lightColor;
    }

    public MiliConfig getMiliConfig() {
        return this.miliConfig;
    }

    public int getMiliDisconnectedReminder() {
        return this.miliConfig.disconnectedReminder;
    }

    public boolean getMiliSleepAssist() {
        return this.miliConfig.sleepAssist;
    }

    public boolean getMiliVibrate() {
        return this.miliConfig.vibrate;
    }

    public String getMiliWearHand() {
        return this.miliConfig.wearHand;
    }

    public int getNeedSyncServer() {
        return this.needSyncServer;
    }

    public String getNickname() {
        return this.nickname;
    }

    public int getPersonInfoUnit() {
        return this.miliConfig.unit;
    }

    public float getTargetWeight() {
        return this.targetWeight;
    }

    public int getTotalDistance() {
        return this.totalSportData != null ? this.totalSportData.getDistance() : SYNC_OK;
    }

    public UserTotalSportData getTotalSportData() {
        return this.totalSportData;
    }

    public int getUnit() {
        return this.miliConfig.unit;
    }

    public int getVersion() {
        return this.version;
    }

    public float getWeight() {
        return this.weight;
    }

    public int getWeightUnit() {
        return this.miliConfig.weightUnit;
    }

    public boolean hasBinded1S() {
        return this.miliConfig.hasHeartRate;
    }

    public boolean isAlarmNotifyEnabled() {
        return this.miliConfig.alarmNotifyEnabled;
    }

    public boolean isEnableConnectedBtAdv() {
        return this.miliConfig.enableConnectedBtAdv;
    }

    public boolean isInComingCallEnabled() {
        boolean z = (this.miliConfig.inComingCallNotifyTime & INCOMING_CALL_DISABLE_BIT) == 0;
        GuliLog.tracePrintInfo(TAG, "isInComingCallEnabled = " + z);
        return z;
    }

    public boolean isSmsNotifyEnabled() {
        return this.miliConfig.smsNotifyEnabled;
    }

    public boolean isValid() {
        return (this.uid == -1 || this.gender == -1 || this.height == -1 || this.weight == -1 || this.age == -1 || getDaySportGoalSteps() <= 0) ? false : true;
    }

    public void setAge(int i) {
        this.age = i;
        GuliLog.tracePrintInfo(TAG, "setAge = " + i);
    }

    public void setBinded1S(boolean z) {
        this.miliConfig.hasHeartRate = z;
    }

    public void setBirthday(String str) {
        this.birthday = str;
    }

    public void setDaySportGoals(int i) {
        this.miliConfig.goalStepsCount = i;
    }

    public void setFirstUseDate(Calendar calendar) {
        this.miliConfig.firstUseDate = calendar;
    }

    public void setInComingCallTime(int i) {
        this.miliConfig.inComingCallNotifyTime = (this.miliConfig.inComingCallNotifyTime & INCOMING_CALL_DISABLE_BIT) | i;
        GuliLog.tracePrintInfo(TAG, "set incoming = " + this.miliConfig.inComingCallNotifyTime);
    }

    public void setMiliColor(String str) {
        this.miliConfig.lightColor = str;
    }

    public void setMiliConfig(MiliConfig miliConfig) {
        this.miliConfig = miliConfig;
    }

    public void setMiliDisconnectedReminder(int i) {
        this.miliConfig.disconnectedReminder = i;
    }

    public void setMiliSleepAssist(boolean z) {
        this.miliConfig.sleepAssist = z;
    }

    public void setMiliVibrate(boolean z) {
        this.miliConfig.vibrate = z;
    }

    public void setMiliWearHand(String str) {
        this.miliConfig.wearHand = str;
    }

    public void setNeedSyncServer(int i) {
        this.needSyncServer |= i;
    }

    public void setTargetWeight(float f) {
        this.targetWeight = f;
    }

    public void setUnit(int i) {
        this.miliConfig.unit = i;
    }

    public void setVersion(int i) {
        this.version = i;
    }

    public void setWeight(float f) {
        this.weight = f;
    }

    public String toString() {
        return Utils.m8049c().toJson((Object) this);
    }
}
